package cn.tedu.note.util;

import java.io.Serializable;

public class JsonResult implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final int SUCCESS = 0;
	public static final int ERROR = 1;

	private int state;
	//错误信息
	private String message;
	//登录正确的时候,返回客户端的数据
	private Object data;
	
	
	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	@Override
	public String toString() {
		return "JsonResult [state=" + state + ", message=" + message + ", data=" + data + "]";
	}

	public JsonResult(){
		
	}
	
	public JsonResult(Throwable e){
		state=ERROR;
		message=e.getMessage();
	}
	
	public JsonResult(Object data){
		state=SUCCESS;
		this.data=data;
	}
	
	
	public JsonResult(int state,Throwable e){
		this.state=state;
		this.message=e.getMessage();
	}
	
	
}










